Imports System.Data.SqlClient
Imports System.Data

Public Class CartasDePorte
    Dim ADNombresDeMP As New ADCono.Productos
    Dim ADClasificaciones As New ADCono.Productos
    Dim ADPaises As New ADCono.CiudadesProvinciasPaises
    Dim ADProvincias As New ADCono.Provincias
    Dim ADLocalidades As New ADCono.Localidades
    Dim ADRazonesSociales As New ADCono.RazonesSociales
    Dim ADCartasDePorte As New ADCono.CartasDePorte

    Public Function ObtenerNombresdeMP()
        Dim DS As New DataSet
        Dim DT As New DataTable
        DS = ADNombresDeMP.ObtenerMateriales("Granos")
        DT = DS.Tables(0)
        Return DT
    End Function

    Public Function ObtenerClasificacionesFiltradas(ByVal Producto As Long)
        Dim DS As New DataSet
        DS = ADClasificaciones.ObtenerClasificaciones(Producto)
        Return DS
    End Function

    Public Function ObtenerPaises()
        Dim DT As New DataTable
        DT = ADPaises.ObtenerCiuProPai()
        Return DT
    End Function

    Public Function ObtenerProvinciasFiltradas(ByVal Pais As Integer)
        Dim DS As New DataSet
        DS = ADProvincias.Obtener(Pais)
        Dim DT As New DataTable
        DT = DS.Tables(0)
        Return DT
    End Function

    Public Function ObtenerLocalidadesFiltradas(ByVal Provincia As Integer)
        Dim DS As New DataSet
        DS = ADLocalidades.Obtener(Provincia)
        Dim DT As New DataTable
        DT = DS.Tables(0)
        Return DT
    End Function

    Public Function ObtenerRazonesSociales(ByVal TDRS As String)
        Dim DT As New DataTable
        DT = ADRazonesSociales.Obtener(TDRS)
        Return DT
    End Function

    Public Sub InsertarCartaDePorte(ByVal Parametros() As String, ByVal IdRecepcion As Integer)
        'Dim ParametrosSQL As SqlParameterCollection
        'ParametrosSQL = New SqlParameterCollection =)

        Dim ParametrosSQL(0) As SqlParameter
        Dim E As Integer = 0
        Dim I

        For Each I In Parametros
            If I.ToString.Split("|")(0).ToString <> "" Then
                ReDim Preserve ParametrosSQL(ParametrosSQL.Length + 1)
                ParametrosSQL(E) = New SqlParameter(I.ToString.Split("|")(1), I.ToString.Split("|")(0))
                E += 1
            End If
        Next
        ReDim Preserve ParametrosSQL(ParametrosSQL.Length + 1)
        ParametrosSQL(ParametrosSQL.Length - 1) = New SqlParameter("@IdRecepcion", IdRecepcion)
        ADCartasDePorte.Insertar(ParametrosSQL)
    End Sub
End Class
